package com.wantong.jianpu.activitys;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import com.lxj.xpopup.XPopup;
import com.wantong.jianpu.BR;
import com.wantong.jianpu.R;
import com.wantong.jianpu.base.BaseXActivity;
import com.wantong.jianpu.databinding.ActivityFaultSuccessBinding;
import com.wantong.jianpu.viewmodels.FaultSuccessViewModel;

/**
 * 确认故障详情
 */
public class FaultSuccessActivity extends BaseXActivity<ActivityFaultSuccessBinding, FaultSuccessViewModel> {

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_fault_success;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initData() {
        super.initData();
        setToolbar(binding.baseToolBar);
        viewModel.id=getIntent().getExtras().getString("id");


        viewModel.confirmStatusEvent.observe(this, strings -> {
            new XPopup.Builder(FaultSuccessActivity.this)
                    .asBottomList("请选择维修状态", strings,
                            (position, text) -> {
                                viewModel.setConfirmStatus(text);
                            }).show();
        });

        viewModel.affectsWorkEvent.observe(this, strings -> {
            new XPopup.Builder(FaultSuccessActivity.this)
                    .asBottomList("请选择是否影响工作", strings,
                            (position, text) -> {
                                viewModel.setAffectsWork(text);
                            }).show();
        });

        viewModel.arriveIntimeEvent.observe(this, strings -> {
            new XPopup.Builder(FaultSuccessActivity.this)
                    .asBottomList("请选择是否及时到达现场", strings,
                            (position, text) -> {
                                viewModel.setArriveIntime(text);
                            }).show();
        });

        viewModel.damageOthersEvent.observe(this, strings -> {
            new XPopup.Builder(FaultSuccessActivity.this)
                    .asBottomList("请选择是否损坏其他设备", strings,
                            (position, text) -> {
                                viewModel.setDamageOthers(text);
                            }).show();
        });
    }

}